package com.kalix.dataPlatform.system.dict.biz;

import com.kalix.framework.core.api.persistence.JsonStatus;
import com.kalix.framework.core.impl.system.BaseDictServiceImpl;
import com.kalix.dataPlatform.system.dict.api.biz.IDataPlatformDictBeanService;
import com.kalix.dataPlatform.system.dict.api.dao.IDataPlatformDictBeanDao;
import com.kalix.dataPlatform.system.dict.entities.DataPlatformDictBean;

import java.util.List;

public class DataPlatformDictBeanServiceImpl extends BaseDictServiceImpl<IDataPlatformDictBeanDao, DataPlatformDictBean>
        implements IDataPlatformDictBeanService {

    public DataPlatformDictBeanServiceImpl() {
        super();
    }

    @Override
    public JsonStatus saveEntity(DataPlatformDictBean entity) {
        Integer maxValue = dao.getFieldMaxValue("value","type='"+entity.getType()+"'");

        maxValue=maxValue+1;
        entity.setValue(maxValue);

        return super.saveEntity(entity);
    }

}
